#include "IMIFadeAction.h"
//
// FadeIn
//
IMIFadeIn* IMIFadeIn::actionWithDuration(float d)
{
    return IMIFadeIn::create(d);
}

IMIFadeIn* IMIFadeIn::create(float d)
{
    IMIFadeIn* pAction = new IMIFadeIn();

    pAction->initWithDuration(d);
    pAction->autorelease();

    return pAction;
}

void IMIFadeIn::update(float time)
{

	CCSprite * temp=(CCSprite *)m_pTarget;
	//m_pTarget->setPositionX(m_pTarget->getPositionX()+1);
    //CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(m_pTarget);
    if (temp)
    {
        temp->setOpacity((GLubyte)(255 * time));

		CCLog("--------------------%f",255 * time);

		int length=temp->getChildrenCount();
		for (int i = 0; i < length; i++)
		{
			
			CCRGBAProtocol *pRGBAProtocol = dynamic_cast<CCRGBAProtocol*>(temp->getChildren()->objectAtIndex(i));
			if(pRGBAProtocol)
			{
				pRGBAProtocol->setOpacity((GLubyte)(255 * time));
			}
		}
    }
    /*m_pTarget->setOpacity((GLubyte)(255 * time));*/
}